package com.eshopping.midleware.impldao;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.eshopping.bean.CatalogueBean;
import com.eshopping.midleware.idao.Catalogue;
import com.eshopping.midleware.idao.Dao;


@Service
public class CatalogueImpl implements Catalogue {

    @Autowired
    private Dao dao;

    @Override
    @Transactional
    public void saveCatalogue(CatalogueBean cat) {
        dao.save(cat);
    }

    @Override
    @Transactional
    public void deleteCatalogue(CatalogueBean cat) {
        dao.delete(cat);
    }

    @Override
    @Transactional
    public void updateCatalogue(CatalogueBean cat) {
        dao.update(cat);
    }
    
    @Override
    @Transactional
    public void saveOrUpdateCatalogue(CatalogueBean cat) {
        dao.saveOrUpdate(cat);
    }

    @Override
    @Transactional
    public CatalogueBean getCataloguerById(long id) {
        return dao.get(CatalogueBean.class, id);
    }

    @Override
    @Transactional
    public CatalogueBean getCatalogue(String name) {
        return dao.get("catalogue1","nameCatalogue", name);
    }

    @Override
    @Transactional
    public List<CatalogueBean> getCatalogue() {
        return dao.getAll(CatalogueBean.class);
    }

}

